
package seeqpod;

import java.io.File;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class SeeqPodGUI extends javax.swing.JFrame implements Runnable {
    private SeeqPodTrack[] tracks;
    private File dir = null;
    private String search;
    private String path = null;
    private ArrayList<SeeqPodTrack[]> trackhistory = new ArrayList<SeeqPodTrack[]>();
    private int count = 0;
    private int page = 0;
    private Thread search1;
    private SearchHistory search_history = new SearchHistory();
    
    public SeeqPodGUI() {
        initComponents();
    }
    

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        VisiblePane = new javax.swing.JLayeredPane();
        SearchTextField = new javax.swing.JTextField();
        TitleLabel = new javax.swing.JLabel();
        Titlebox = new javax.swing.JTextField();
        ArtistLabel = new javax.swing.JLabel();
        Artistbox = new javax.swing.JTextField();
        AlbumLabel = new javax.swing.JLabel();
        AlbumBox = new javax.swing.JTextField();
        GenreLabel = new javax.swing.JLabel();
        GenreBox = new javax.swing.JTextField();
        LocationLabel = new javax.swing.JLabel();
        LocationBox = new javax.swing.JTextArea();
        result1 = new javax.swing.JTextField();
        result2 = new javax.swing.JTextField();
        result3 = new javax.swing.JTextField();
        result4 = new javax.swing.JTextField();
        result5 = new javax.swing.JTextField();
        result6 = new javax.swing.JTextField();
        result7 = new javax.swing.JTextField();
        result8 = new javax.swing.JTextField();
        result9 = new javax.swing.JTextField();
        result10 = new javax.swing.JTextField();
        checkbox1 = new javax.swing.JCheckBox();
        checkbox2 = new javax.swing.JCheckBox();
        checkbox3 = new javax.swing.JCheckBox();
        checkbox4 = new javax.swing.JCheckBox();
        checkbox5 = new javax.swing.JCheckBox();
        checkbox6 = new javax.swing.JCheckBox();
        checkbox7 = new javax.swing.JCheckBox();
        checkbox8 = new javax.swing.JCheckBox();
        checkbox9 = new javax.swing.JCheckBox();
        checkbox10 = new javax.swing.JCheckBox();
        pagenumber = new javax.swing.JLabel();
        prevpagebutton = new javax.swing.JButton();
        downloadbutton = new javax.swing.JButton();
        nextpagebutton = new javax.swing.JButton();
        background = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("shmolderin seeqpod");
        setIconImage(new ImageIcon(getClass().getResource("/seeqpod/images/seeqpodlogo.png")).getImage());
        setLocationByPlatform(true);
        setMaximizedBounds(new java.awt.Rectangle(0, 0, 504, 360));
        setMinimumSize(new java.awt.Dimension(504, 360));
        setName("shmolderin seeqpod"); // NOI18N
        setResizable(false);

        SearchTextField.setFont(new java.awt.Font("Cambria", 1, 24));
        SearchTextField.setForeground(new java.awt.Color(40, 111, 176));
        SearchTextField.setText("Search");
        SearchTextField.setToolTipText("Click to erase contents and scroll to view history");
        SearchTextField.setBorder(null);
        SearchTextField.setOpaque(false);
        SearchTextField.addMouseWheelListener(new java.awt.event.MouseWheelListener() {
            public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
                SearchTextFieldMouseWheelMoved(evt);
            }
        });
        SearchTextField.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SearchTextFieldMouseClicked(evt);
            }
        });
        SearchTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                SearchTextFieldKeyReleased(evt);
            }
        });
        SearchTextField.setBounds(80, 30, 310, 36);
        VisiblePane.add(SearchTextField, javax.swing.JLayeredPane.DEFAULT_LAYER);

        TitleLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        TitleLabel.setText("Title: ");
        TitleLabel.setEnabled(false);
        TitleLabel.setBounds(340, 100, 130, 20);
        VisiblePane.add(TitleLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Titlebox.setEditable(false);
        Titlebox.setFont(new java.awt.Font("Cambria", 1, 12));
        Titlebox.setBorder(null);
        Titlebox.setFocusable(false);
        Titlebox.setOpaque(false);
        Titlebox.setBounds(340, 120, 130, -1);
        VisiblePane.add(Titlebox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        ArtistLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        ArtistLabel.setText("Artist: ");
        ArtistLabel.setEnabled(false);
        ArtistLabel.setBounds(340, 140, 130, 20);
        VisiblePane.add(ArtistLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        Artistbox.setEditable(false);
        Artistbox.setFont(new java.awt.Font("Cambria", 1, 12));
        Artistbox.setBorder(null);
        Artistbox.setFocusable(false);
        Artistbox.setOpaque(false);
        Artistbox.setBounds(340, 160, 130, -1);
        VisiblePane.add(Artistbox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        AlbumLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        AlbumLabel.setText("Album:");
        AlbumLabel.setEnabled(false);
        AlbumLabel.setBounds(340, 180, 130, 20);
        VisiblePane.add(AlbumLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        AlbumBox.setEditable(false);
        AlbumBox.setFont(new java.awt.Font("Cambria", 1, 12));
        AlbumBox.setBorder(null);
        AlbumBox.setFocusable(false);
        AlbumBox.setOpaque(false);
        AlbumBox.setBounds(340, 200, 130, -1);
        VisiblePane.add(AlbumBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        GenreLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        GenreLabel.setText("Genre: ");
        GenreLabel.setEnabled(false);
        GenreLabel.setBounds(340, 220, 130, 20);
        VisiblePane.add(GenreLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        GenreBox.setEditable(false);
        GenreBox.setFont(new java.awt.Font("Cambria", 1, 12));
        GenreBox.setBorder(null);
        GenreBox.setFocusable(false);
        GenreBox.setOpaque(false);
        GenreBox.setBounds(340, 240, 130, -1);
        VisiblePane.add(GenreBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LocationLabel.setFont(new java.awt.Font("Cambria", 0, 13));
        LocationLabel.setText("Location: ");
        LocationLabel.setEnabled(false);
        LocationLabel.setBounds(340, 260, 130, 20);
        VisiblePane.add(LocationLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        LocationBox.setColumns(20);
        LocationBox.setEditable(false);
        LocationBox.setFont(new java.awt.Font("Cambria", 0, 8));
        LocationBox.setRows(1);
        LocationBox.setOpaque(false);
        LocationBox.setBounds(337, 280, 140, 30);
        VisiblePane.add(LocationBox, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result1.setEditable(false);
        result1.setFont(new java.awt.Font("Cambria", 1, 12));
        result1.setForeground(new java.awt.Color(150, 194, 31));
        result1.setAlignmentX(0.0F);
        result1.setAlignmentY(0.0F);
        result1.setBorder(null);
        result1.setOpaque(false);
        result1.setRequestFocusEnabled(false);
        result1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result1MouseClicked(evt);
            }
        });
        result1.setBounds(57, 105, 273, 20);
        VisiblePane.add(result1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result2.setEditable(false);
        result2.setFont(new java.awt.Font("Cambria", 1, 12));
        result2.setForeground(new java.awt.Color(150, 194, 31));
        result2.setAlignmentX(0.0F);
        result2.setAlignmentY(0.0F);
        result2.setBorder(null);
        result2.setOpaque(false);
        result2.setRequestFocusEnabled(false);
        result2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result2MouseClicked(evt);
            }
        });
        result2.setBounds(57, 125, 273, 20);
        VisiblePane.add(result2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result3.setEditable(false);
        result3.setFont(new java.awt.Font("Cambria", 1, 12));
        result3.setForeground(new java.awt.Color(150, 194, 31));
        result3.setAlignmentX(0.0F);
        result3.setAlignmentY(0.0F);
        result3.setBorder(null);
        result3.setOpaque(false);
        result3.setRequestFocusEnabled(false);
        result3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result3MouseClicked(evt);
            }
        });
        result3.setBounds(57, 145, 273, 20);
        VisiblePane.add(result3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result4.setEditable(false);
        result4.setFont(new java.awt.Font("Cambria", 1, 12));
        result4.setForeground(new java.awt.Color(150, 194, 31));
        result4.setAlignmentX(0.0F);
        result4.setAlignmentY(0.0F);
        result4.setBorder(null);
        result4.setOpaque(false);
        result4.setRequestFocusEnabled(false);
        result4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result4MouseClicked(evt);
            }
        });
        result4.setBounds(57, 165, 273, 20);
        VisiblePane.add(result4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result5.setEditable(false);
        result5.setFont(new java.awt.Font("Cambria", 1, 12));
        result5.setForeground(new java.awt.Color(150, 194, 31));
        result5.setAlignmentX(0.0F);
        result5.setAlignmentY(0.0F);
        result5.setBorder(null);
        result5.setOpaque(false);
        result5.setRequestFocusEnabled(false);
        result5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result5MouseClicked(evt);
            }
        });
        result5.setBounds(57, 185, 273, 20);
        VisiblePane.add(result5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result6.setEditable(false);
        result6.setFont(new java.awt.Font("Cambria", 1, 12));
        result6.setForeground(new java.awt.Color(150, 194, 31));
        result6.setAlignmentX(0.0F);
        result6.setAlignmentY(0.0F);
        result6.setBorder(null);
        result6.setOpaque(false);
        result6.setRequestFocusEnabled(false);
        result6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result6MouseClicked(evt);
            }
        });
        result6.setBounds(57, 205, 273, 20);
        VisiblePane.add(result6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result7.setEditable(false);
        result7.setFont(new java.awt.Font("Cambria", 1, 12));
        result7.setForeground(new java.awt.Color(150, 194, 31));
        result7.setAlignmentX(0.0F);
        result7.setAlignmentY(0.0F);
        result7.setBorder(null);
        result7.setOpaque(false);
        result7.setRequestFocusEnabled(false);
        result7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result7MouseClicked(evt);
            }
        });
        result7.setBounds(57, 225, 273, 20);
        VisiblePane.add(result7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result8.setEditable(false);
        result8.setFont(new java.awt.Font("Cambria", 1, 12));
        result8.setForeground(new java.awt.Color(150, 194, 31));
        result8.setAlignmentX(0.0F);
        result8.setAlignmentY(0.0F);
        result8.setBorder(null);
        result8.setOpaque(false);
        result8.setRequestFocusEnabled(false);
        result8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result8MouseClicked(evt);
            }
        });
        result8.setBounds(57, 245, 273, 20);
        VisiblePane.add(result8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result9.setEditable(false);
        result9.setFont(new java.awt.Font("Cambria", 1, 12));
        result9.setForeground(new java.awt.Color(150, 194, 31));
        result9.setAlignmentX(0.0F);
        result9.setAlignmentY(0.0F);
        result9.setBorder(null);
        result9.setOpaque(false);
        result9.setRequestFocusEnabled(false);
        result9.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result9MouseClicked(evt);
            }
        });
        result9.setBounds(57, 265, 273, 20);
        VisiblePane.add(result9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        result10.setEditable(false);
        result10.setFont(new java.awt.Font("Cambria", 1, 12));
        result10.setForeground(new java.awt.Color(150, 194, 31));
        result10.setAlignmentX(0.0F);
        result10.setAlignmentY(0.0F);
        result10.setBorder(null);
        result10.setOpaque(false);
        result10.setRequestFocusEnabled(false);
        result10.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                result10MouseClicked(evt);
            }
        });
        result10.setBounds(57, 285, 273, 20);
        VisiblePane.add(result10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox1.setToolTipText("Click to add to download Que");
        checkbox1.setContentAreaFilled(false);
        checkbox1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox1.setEnabled(false);
        checkbox1.setFocusPainted(false);
        checkbox1.setFocusable(false);
        checkbox1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox1.setRequestFocusEnabled(false);
        checkbox1.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox1.setBounds(31, 105, 20, 20);
        VisiblePane.add(checkbox1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox2.setToolTipText("Click to add to download Que");
        checkbox2.setContentAreaFilled(false);
        checkbox2.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox2.setEnabled(false);
        checkbox2.setFocusPainted(false);
        checkbox2.setFocusable(false);
        checkbox2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox2.setRequestFocusEnabled(false);
        checkbox2.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox2.setBounds(31, 125, 20, 20);
        VisiblePane.add(checkbox2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox3.setToolTipText("Click to add to download Que");
        checkbox3.setContentAreaFilled(false);
        checkbox3.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox3.setEnabled(false);
        checkbox3.setFocusPainted(false);
        checkbox3.setFocusable(false);
        checkbox3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox3.setRequestFocusEnabled(false);
        checkbox3.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox3.setBounds(31, 145, 20, 20);
        VisiblePane.add(checkbox3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox4.setToolTipText("Click to add to download Que");
        checkbox4.setContentAreaFilled(false);
        checkbox4.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox4.setEnabled(false);
        checkbox4.setFocusPainted(false);
        checkbox4.setFocusable(false);
        checkbox4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox4.setRequestFocusEnabled(false);
        checkbox4.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox4.setBounds(31, 165, 20, 20);
        VisiblePane.add(checkbox4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox5.setToolTipText("Click to add to download Que");
        checkbox5.setContentAreaFilled(false);
        checkbox5.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox5.setEnabled(false);
        checkbox5.setFocusPainted(false);
        checkbox5.setFocusable(false);
        checkbox5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox5.setRequestFocusEnabled(false);
        checkbox5.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox5.setBounds(31, 185, 20, 20);
        VisiblePane.add(checkbox5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox6.setToolTipText("Click to add to download Que");
        checkbox6.setContentAreaFilled(false);
        checkbox6.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox6.setEnabled(false);
        checkbox6.setFocusPainted(false);
        checkbox6.setFocusable(false);
        checkbox6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox6.setRequestFocusEnabled(false);
        checkbox6.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox6.setBounds(31, 205, 20, 20);
        VisiblePane.add(checkbox6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox7.setToolTipText("Click to add to download Que");
        checkbox7.setContentAreaFilled(false);
        checkbox7.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox7.setEnabled(false);
        checkbox7.setFocusPainted(false);
        checkbox7.setFocusable(false);
        checkbox7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox7.setRequestFocusEnabled(false);
        checkbox7.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox7.setBounds(31, 225, 20, 20);
        VisiblePane.add(checkbox7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox8.setToolTipText("Click to add to download Que");
        checkbox8.setContentAreaFilled(false);
        checkbox8.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox8.setEnabled(false);
        checkbox8.setFocusPainted(false);
        checkbox8.setFocusable(false);
        checkbox8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox8.setRequestFocusEnabled(false);
        checkbox8.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox8.setBounds(31, 245, 20, 20);
        VisiblePane.add(checkbox8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox9.setToolTipText("Click to add to download Que");
        checkbox9.setContentAreaFilled(false);
        checkbox9.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox9.setEnabled(false);
        checkbox9.setFocusPainted(false);
        checkbox9.setFocusable(false);
        checkbox9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox9.setRequestFocusEnabled(false);
        checkbox9.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox9.setBounds(31, 265, 20, 20);
        VisiblePane.add(checkbox9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        checkbox10.setToolTipText("Click to add to download Que");
        checkbox10.setContentAreaFilled(false);
        checkbox10.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/transparent.png"))); // NOI18N
        checkbox10.setEnabled(false);
        checkbox10.setFocusPainted(false);
        checkbox10.setFocusable(false);
        checkbox10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        checkbox10.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        checkbox10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/unchecked.png"))); // NOI18N
        checkbox10.setRequestFocusEnabled(false);
        checkbox10.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/checked.png"))); // NOI18N
        checkbox10.setBounds(31, 285, 20, 20);
        VisiblePane.add(checkbox10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        pagenumber.setFont(new java.awt.Font("Cambria", 1, 14));
        pagenumber.setForeground(new java.awt.Color(255, 255, 255));
        pagenumber.setFocusable(false);
        pagenumber.setBounds(148, 73, 20, 20);
        VisiblePane.add(pagenumber, javax.swing.JLayeredPane.DEFAULT_LAYER);

        prevpagebutton.setContentAreaFilled(false);
        prevpagebutton.setFocusPainted(false);
        prevpagebutton.setFocusable(false);
        prevpagebutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prevpagebuttonActionPerformed(evt);
            }
        });
        prevpagebutton.setBounds(26, 314, 40, 30);
        VisiblePane.add(prevpagebutton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        downloadbutton.setContentAreaFilled(false);
        downloadbutton.setFocusPainted(false);
        downloadbutton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                downloadbuttonMouseClicked(evt);
            }
        });
        downloadbutton.setBounds(66, 314, 371, 29);
        VisiblePane.add(downloadbutton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        nextpagebutton.setContentAreaFilled(false);
        nextpagebutton.setFocusPainted(false);
        nextpagebutton.setFocusable(false);
        nextpagebutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextpagebuttonActionPerformed(evt);
            }
        });
        nextpagebutton.setBounds(440, 314, 40, 30);
        VisiblePane.add(nextpagebutton, javax.swing.JLayeredPane.DEFAULT_LAYER);

        background.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seeqpod/images/seeqpod.png"))); // NOI18N
        background.setFocusable(false);
        background.setRequestFocusEnabled(false);
        background.setBounds(0, 0, 504, 360);
        VisiblePane.add(background, javax.swing.JLayeredPane.DEFAULT_LAYER);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(VisiblePane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(VisiblePane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SearchTextFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SearchTextFieldMouseClicked
        SearchTextField.setText("");
    }//GEN-LAST:event_SearchTextFieldMouseClicked

    private void SearchTextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SearchTextFieldKeyReleased
        if (search1 != null) {
            try {
                if (search1.isAlive()) {
                    search1.interrupt();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        search1 = new Thread(this);
        search1.start();
    }//GEN-LAST:event_SearchTextFieldKeyReleased

    private void downloadbuttonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_downloadbuttonMouseClicked
        for(byte i = 0; i < 10; i++){
            if(checkboxes[i].isSelected()){
                if(path == null)
                    path = chooseFile().getPath() + "/";
                String str = (path + tracks[i].getLocation().substring(tracks[i].getLocation().lastIndexOf("/") + 1));
                new Download(tracks[i].getLocation(), new File(str)).start();
            }   
        }
    }//GEN-LAST:event_downloadbuttonMouseClicked

    private void SearchTextFieldMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_SearchTextFieldMouseWheelMoved
        try {
            SearchTextField.setText(search_history.get(count));
            count++;
        } catch (IndexOutOfBoundsException e) {
            count = 0;
        }
    }//GEN-LAST:event_SearchTextFieldMouseWheelMoved

    private void result1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result1MouseClicked
        focusGained((byte)0);
    }//GEN-LAST:event_result1MouseClicked

    private void result2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result2MouseClicked
        focusGained((byte)1);
    }//GEN-LAST:event_result2MouseClicked

    private void result3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result3MouseClicked
        focusGained((byte)2);
    }//GEN-LAST:event_result3MouseClicked

    private void result4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result4MouseClicked
        focusGained((byte)3);
    }//GEN-LAST:event_result4MouseClicked

    private void result5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result5MouseClicked
        focusGained((byte)4);
    }//GEN-LAST:event_result5MouseClicked

    private void result6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result6MouseClicked
        focusGained((byte)5);
    }//GEN-LAST:event_result6MouseClicked

    private void result7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result7MouseClicked
        focusGained((byte)6);
    }//GEN-LAST:event_result7MouseClicked

    private void result8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result8MouseClicked
        focusGained((byte)7);
    }//GEN-LAST:event_result8MouseClicked

    private void result9MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result9MouseClicked
        focusGained((byte)8);
    }//GEN-LAST:event_result9MouseClicked

    private void result10MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_result10MouseClicked
        focusGained((byte)9);
    }//GEN-LAST:event_result10MouseClicked

    private void prevpagebuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevpagebuttonActionPerformed
        if(page >= 1){
            cleanup();
            pagenumber.setText("" + page);
            page--;
            tracks = trackhistory.get(page);
            applyTitles();
        }
    }//GEN-LAST:event_prevpagebuttonActionPerformed

    private void nextpagebuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextpagebuttonActionPerformed
        trackhistory.add(tracks);
        cleanup();
        page++;
        tracks = new SeeqPod().search(search, 10* page);
        pagenumber.setText("" + (page + 1));
        applyTitles();
    }//GEN-LAST:event_nextpagebuttonActionPerformed
    public File chooseFile(){
        JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(1);
        fc.setDialogTitle("Choose Directory to Save Audio");
        int result = fc.showSaveDialog(null);
        if(result == JFileChooser.APPROVE_OPTION)
            dir = fc.getSelectedFile();
        return dir;
    }
    
    private void updateresults(){
        results[0] = result1;
        results[1] = result2;
        results[2] = result3;
        results[3] = result4;
        results[4] = result5;
        results[5] = result6;
        results[6] = result7;
        results[7] = result8;
        results[8] = result9;
        results[9] = result10;
    }
    private void updatecheckboxes(){
        checkboxes[0] = checkbox1;
        checkboxes[1] = checkbox2;
        checkboxes[2] = checkbox3;
        checkboxes[3] = checkbox4;
        checkboxes[4] = checkbox5;
        checkboxes[5] = checkbox6;
        checkboxes[6] = checkbox7;
        checkboxes[7] = checkbox8;
        checkboxes[8] = checkbox9;
        checkboxes[9] = checkbox10;
        
    }
    public void run() {
        cleanup();
        search = SearchTextField.getText();
        tracks = new SeeqPod().search(search);
        applyTitles();
    }

    public void focusGained(byte i) {
        for(byte e = 0; e < 10; e++){
            results[e].setBorder(null);
        }
        AlbumLabel.setEnabled(true);
        AlbumBox.setText(tracks[i].getAlbum());
        ArtistLabel.setEnabled(true);
        Artistbox.setText(tracks[i].getCreator());
        GenreLabel.setEnabled(true);
        GenreBox.setText(tracks[i].getGenre());
        TitleLabel.setEnabled(true);
        Titlebox.setText(tracks[i].getTitle());
        LocationLabel.setEnabled(true);
        LocationBox.setText(tracks[i].getLocation());
        results[i].setBorder(new javax.swing.border.LineBorder(new java.awt.Color(40, 111, 176), 1, true));
    }
    
    private void applyTitles(){
        updateresults();
        updatecheckboxes();
        if (tracks != null) {
            for (byte i = 0; i < tracks.length; i++) {
                results[i].setEnabled(true);
                results[i].setText(tracks[i].getTitle());
                checkboxes[i].setEnabled(true);
            }
            checktracks();
        }
    }

    private void checktracks(){
        URLCheckThread uct[] = new URLCheckThread[tracks.length];
        for(byte e = 0; e < tracks.length; e++){
            uct[e] = new URLCheckThread(tracks[e].getLocation());
            uct[e].start();
        }
        for(byte i = 0; i < tracks.length; i++){
            try {
                uct[i].join();
                if (!uct[i].getStatus()) {
                    results[i].setEnabled(false);
                    checkboxes[i].setEnabled(false);
                }
            } catch (InterruptedException ex) {
            }
        }
    }
    private void cleanup() {
        updateresults();
        updatecheckboxes();
        for (byte i = 0; i < 10; i++) {
            checkboxes[i].setEnabled(false);
            results[i].setBorder(null);
            results[i].setEnabled(false);            
            AlbumLabel.setEnabled(false);
            AlbumBox.setText("");
            ArtistLabel.setEnabled(false);
            Artistbox.setText("");
            GenreLabel.setEnabled(false);
            GenreBox.setText("");
            TitleLabel.setEnabled(false);
            Titlebox.setText("");
            LocationLabel.setEnabled(false);
            LocationBox.setText("");
        }
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (UnsupportedLookAndFeelException e) {
                } catch (ClassNotFoundException e) {
                } catch (InstantiationException e) {
                } catch (IllegalAccessException e) {
                }
                new SeeqPodGUI().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField AlbumBox;
    private javax.swing.JLabel AlbumLabel;
    private javax.swing.JLabel ArtistLabel;
    private javax.swing.JTextField Artistbox;
    private javax.swing.JTextField GenreBox;
    private javax.swing.JLabel GenreLabel;
    private javax.swing.JTextArea LocationBox;
    private javax.swing.JLabel LocationLabel;
    private javax.swing.JTextField SearchTextField;
    private javax.swing.JLabel TitleLabel;
    private javax.swing.JTextField Titlebox;
    private javax.swing.JLayeredPane VisiblePane;
    private javax.swing.JLabel background;
    private javax.swing.JCheckBox checkbox1;
    private javax.swing.JCheckBox checkbox10;
    private javax.swing.JCheckBox checkbox2;
    private javax.swing.JCheckBox checkbox3;
    private javax.swing.JCheckBox checkbox4;
    private javax.swing.JCheckBox checkbox5;
    private javax.swing.JCheckBox checkbox6;
    private javax.swing.JCheckBox checkbox7;
    private javax.swing.JCheckBox checkbox8;
    private javax.swing.JCheckBox checkbox9;
    private javax.swing.JButton downloadbutton;
    private javax.swing.JButton nextpagebutton;
    private javax.swing.JLabel pagenumber;
    private javax.swing.JButton prevpagebutton;
    private javax.swing.JTextField result1;
    private javax.swing.JTextField result10;
    private javax.swing.JTextField result2;
    private javax.swing.JTextField result3;
    private javax.swing.JTextField result4;
    private javax.swing.JTextField result5;
    private javax.swing.JTextField result6;
    private javax.swing.JTextField result7;
    private javax.swing.JTextField result8;
    private javax.swing.JTextField result9;
    // End of variables declaration//GEN-END:variables
    
    javax.swing.JCheckBox checkboxes[] = {
        checkbox1,
        checkbox2,
        checkbox3,
        checkbox4,
        checkbox5,
        checkbox6,
        checkbox7,
        checkbox8,
        checkbox9,
        checkbox10
    };
    javax.swing.JTextField results[] = {
        result1,
        result2,
        result3,
        result4,
        result5,
        result6,
        result7,
        result8,
        result9,
        result10,
    };

}
